/* 
 * This javascript file is necessary for the functioning of the theme
 */

$(document).ready(function(){ 
    
    $("#formID").validationEngine('attach');
        
    $('.date').datepicker({
        'dateFormat': 'd/m/yy',
        'changeMonth': true,
        'changeYear': true
    });
    $('.multidatepicker').datepick({ 
        multiSelect: 999,
        multiSeparator: ', '
    });
    $('.time').timepicker({});
    
    $( ".tabs" ).tabs();
    
    $('.actions').bind('change', function () {
        var url = $(this).val();
        if (url) {
            window.location = url;
        }
        return false;
    });
    
    $("ul.sf-menu").superfish({
        delay:       500,
        animation:   {
            opacity:'show',
            height:'show'
        }
    });
        
    $('.datatables').dataTable({
        "sPaginationType": "full_numbers",
        "bJQueryUI": true
    });
    
    $("#loginarrow").click(function() {
        $("#logindrop").toggle("slow");
        return false;
    });

    $("#search").click(function() {
        $("#searchdrop").toggle("slow");
        return false;
    });
        
    $(".notification").click(function() {
        $(this).fadeOut("slow");
    });
    
    /*
     * Function: fnGetHiddenTrNodes
     * Purpose:  Get all of the hidden TR nodes (i.e. the ones which aren't on display)
     * Returns:  array:
     * Inputs:   object:oSettings - DataTables settings object
     */
    $.fn.dataTableExt.oApi.fnGetHiddenTrNodes = function ( oSettings )
    {
        /* Note the use of a DataTables 'private' function thought the 'oApi' object */
        var anNodes = this.oApi._fnGetTrNodes( oSettings );
        var anDisplay = $('tbody tr', oSettings.nTable);

        /* Remove nodes which are being displayed */
        for ( var i=0 ; i<anDisplay.length ; i++ )
        {
            var iIndex = jQuery.inArray( anDisplay[i], anNodes );
            if ( iIndex != -1 )
            {
                anNodes.splice( iIndex, 1 );
            }
        }

        /* Fire back the array to the caller */
        return anNodes;
    }
});